package com.jswl.training.stomp.stomp.controller;

import com.jswl.training.stomp.stomp.model.ClientMessage;
import com.jswl.training.stomp.stomp.model.ServerMessage;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.stereotype.Controller;

@Controller
public class StompController {


    @MessageMapping("/sendTest")
    @SendTo("/topic/subscribeTest")
    public ServerMessage sendDemo(ClientMessage message) {
        return new ServerMessage("server你发送的消息为:" + message.getName());
    }

    @SubscribeMapping("/subscribeTest")
    public ServerMessage sub() {
        return new ServerMessage("感谢你订阅了我。。。");
    }


}
